package com.sogo;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONObject;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.database.Cursor;


/*This class searches friends on MySQL database then sends the results to the addfriend activity*/
public class SearchFriend extends Activity{
	
	private EditText etUsername;
	private EditText etFirstName;
	private EditText etLastName;
	private Button btnSearchFriend;
	final DBAdapter db = new DBAdapter(this);
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.searchfriend);
		etUsername = (EditText)findViewById(R.id.userName);
		etFirstName=(EditText)findViewById(R.id.firstName);
		etLastName=(EditText)findViewById(R.id.lastName);
		btnSearchFriend = (Button)findViewById(R.id.searchfriend_button);
		
		btnSearchFriend.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				String userName = etUsername.getText().toString();
				String firstName=etFirstName.getText().toString();
				String lastName=etLastName.getText().toString();
				
				Intent s = new Intent(getApplicationContext(), AddFriend.class);
				s.putExtra("user",userName);
				s.putExtra("first",firstName);
				s.putExtra("last",lastName);
				startActivity(s);
				finish();
			}
		});
	}
}
